#include <include/entity.h>
#include <include/Game/Game.h>
#include "event.h"
#include "sdk/misc.h"
using namespace std;

bool skill::TriggeredDeath::use(Game *g, const std::vector<std::string> &params) {
    cerr << "TriggeredDeath begin" << endl;
    vector<string> inSet, outSet;
    SplitString(origin->properties["link_in"], inSet, "|");
    SplitString(origin->properties["link_out"], outSet, "|");
    for (auto i: inSet) if (i.size() > 0){
        auto actor = g->entityManager.findEntityByID(i);
        actor->useSkill("Disconnect", {origin->id});
    }
    for (auto i: outSet) if (i.size() > 0){
        auto actor = g->entityManager.findEntityByID(i);
        origin->useSkill("Disconnect", {actor->id});
    }
    origin->properties["dead"]= "true";
    (dynamic_cast<Actor*>(origin))->setPos(Point(-1, -1));
    cerr << "TriggeredDeath end" << endl;
    return Skill::use(g, params);
}
